package com.itboye.jinpuyiyuan.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.itboye.jinpuyiyuan.MainActivity;
import com.itboye.jinpuyiyuan.R;
import com.itboye.jinpuyiyuan.base.BaseActivity;
import com.itboye.jinpuyiyuan.fragment.HomeFragment;
import com.jude.rollviewpager.RollPagerView;
import com.jude.rollviewpager.adapter.StaticPagerAdapter;
import com.jude.rollviewpager.hintview.IconHintView;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by Administrator on 2017/12/19 0019.
 */

public class GuideActivity1 extends BaseActivity {
    private RollPagerView rollPv;
    private ImageNormalAdapter mLoopAdapter;
    private int [] imgs={R.drawable.yindao2x_01,R.drawable.yindao2x_02,R.drawable.yindao2x_03};
    private Timer timer;
    @Override
    protected void onCreate(Bundle arg0) {
        super.onCreate(arg0);
        setContentView(R.layout.activity_guide_01);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().setStatusBarColor(Color.TRANSPARENT);
        }
        initViewData();

    }

    private void initViewData() {
        timer=new Timer();
        rollPv.setPlayDelay(2000);
        rollPv.setAdapter(new ImageNormalAdapter(imgs));
        rollPv.setHintView(null);
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                startActivity(new Intent(GuideActivity1.this, MainActivity.class));
                GuideActivity1.this.finish();
            }
        },5000);
    }
    private class ImageNormalAdapter extends StaticPagerAdapter {
        int [] imgs;
        public ImageNormalAdapter(int [] imgs){
           this.imgs=imgs;
        }
        @Override
        public View getView(ViewGroup container, int position) {
            ImageView view = new ImageView(container.getContext());
            view.setScaleType(ImageView.ScaleType.CENTER_CROP);
            view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
            view.setImageResource(imgs[position]);
            return view;
        }

        @Override
        public int getCount() {
            return imgs.length;
        }
    }
}
